﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MMITDomain.Abstract;
using MMITDomain.Entities;

namespace MMITDomain.Concrete
{
    public class EFTransactionTypeRepository : ITransactionTypeRepository
    {
        EFDbContext dbContext = new EFDbContext();

        #region ITransactionTypeRepository Members

        public IQueryable<TransactionType> TransactionTypes
        {
            get 
            {
                return dbContext.TransactionTypes;
            }
        }

        public void SaveTransactionType(TransactionType objTransactionType)
        {
            if (objTransactionType.Id == 0)
            {
                dbContext.TransactionTypes.Add(objTransactionType);
            }

            dbContext.SaveChanges();
        }

        public void DeleteTransactionType(TransactionType objTransactionType)
        {
            dbContext.TransactionTypes.Remove(objTransactionType);
        }

        public TransactionType GetTransactionTypeById(int iTransactionTypeId)
        {
            return dbContext.TransactionTypes.Find(iTransactionTypeId);
        }

        #endregion
    }
}
